Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Tuya MMW sensors: _TZE204_qasjif9e, _TZE204_sxm7l9xa, _TZE204_e5m9c5hl #2525

Open
wants to merge 25 commits into
base: dev
Choose a base branch
from

Conversation

pgroene
Copy link

@pgroene pgroene commented Aug 12, 2023

Proposed change

Add support for Tuya MMW sensor _TZE204_qasjif9e and _TZE204_sxm7l9xa

Additional information

Added support based on example code in #2378 (comment)
#2510

Checklist

  • The changes are tested and work correctly
  • pre-commit checks pass / the code has been formatted using Black
  • Tests have been added to verify that the new code works

@codecov
Copy link

codecov bot commented Aug 12, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.41%. Comparing base (aeca76d) to head (c40f80a).
Report is 224 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #2525      +/-   ##
==========================================
+ Coverage   87.35%   87.41%   +0.05%     
==========================================
  Files         287      287              
  Lines        8835     8875      +40     
==========================================
+ Hits         7718     7758      +40     
  Misses       1117     1117              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Address flagged issue in build pipeline
Address formatting flagged in build pipeline
fix formatting
@pgroene
Copy link
Author

pgroene commented Aug 12, 2023

How to add unittests and what kind of unittests? Or how to grt this merged?

@MichalLytek
Copy link

MichalLytek commented Aug 22, 2023

Added support based on example code in #2378 (comment)

This example code does not support target_distance nor illuminance_lux, available in Z2MQTT.
Is it possible to add this?

@evgenln
Copy link
Contributor

evgenln commented Aug 23, 2023

it supports but there are limitations.
To get illuminance_lux, restart the HA host (not only reload ZHA).
To get target_distance it should be exposed in ZHA (is not part of this PR)

@pgroene
Copy link
Author

pgroene commented Aug 26, 2023

it supports but there are limitations. To get illuminance_lux, restart the HA host (not only reload ZHA). To get target_distance it should be exposed in ZHA (is not part of this PR)

Yes, the lux is working. I tried to get the target distance working. But did not see what was missing. @evgenln if you have any pointers, i can have a look in an other pr.
Im running this code for about 2 weeks with any issues. And ordered 18 more sensors, it would be nice to run them without custom deployment actions.

Add support for TZE204_sxm7l9xa
fix tailing whitespaces
add missing enter
fix showing lux for _TZE204_sxm7l9xa
@pgroene
Copy link
Author

pgroene commented Sep 6, 2023

Merged the changes from this pr @arbrandes:
#2485

into this pr, it now does _TZE204_sxm7l9xa
Tested both the new devices

fix the white spaces
@pgroene
Copy link
Author

pgroene commented Sep 6, 2023

It seems I broke the _TZE204_qasjif9e, I'll update when I have a fix

fixed _TZE204_qasjif9e
but lost lux on _TZE204_sxm7l9xa
@pgroene
Copy link
Author

pgroene commented Sep 6, 2023

It seems latest version both sensors work correctly for presence and lux

@pgroene pgroene changed the title Add support for Tuya MMW sensor _TZE204_qasjif9e Add support for Tuya MMW sensor _TZE204_qasjif9e and _TZE204_qasjif9e Sep 6, 2023
@pgroene pgroene changed the title Add support for Tuya MMW sensor _TZE204_qasjif9e and _TZE204_qasjif9e Add support for Tuya MMW sensor _TZE204_qasjif9e and _TZE204_sxm7l9xa Sep 6, 2023
@TheJulianJES TheJulianJES added the Tuya Request/PR regarding a Tuya device label Sep 8, 2023
@ashleycawley
Copy link

I recently got a _TZE204_qasjif9e mmWave motion sensor and was trying to set it up. Can I assist in testing at all? I'm an amateur and coding so may not be able to help there, but willing to test and report back if I can help. The device was introduced to the ZHA network as normal and appears, just no useful entities or functions.

@pgroene
Copy link
Author

pgroene commented Sep 15, 2023

I recently got a _TZE204_qasjif9e mmWave motion sensor and was trying to set it up. Can I assist in testing at all? I'm an amateur and coding so may not be able to help there, but willing to test and report back if I can help. The device was introduced to the ZHA network as normal and appears, just no useful entities or functions.

You can test the file from the PR:

Create a custom quirk dir in HA, e.g., /config/custom_zha_quirks
In configuration.yaml, point to this directory:
zha:
custom_quirks_path: /config/custom_zha_quirks/
in this directory, create the python file with content of the quirk

@edwiness10
Copy link

Hello, I recently purchased two mmWave modules (_TZE204_qasjif9e and _TZE204_sxm7l9xa). With the latest change of ts0601_motion.py in the path /config/custom_zha_quirks/ I managed to configure correctly with ZHA. I can already see the entities. If there is any test I would be happy to do.

@ashleycawley
Copy link

You can test the file from the PR:

Create a custom quirk dir in HA, e.g., /config/custom_zha_quirks In configuration.yaml, point to this directory: zha: custom_quirks_path: /config/custom_zha_quirks/ in this directory, create the python file with content of the quirk

This is working great for me! Thank you for all your efforts with this.

@pgroene
Copy link
Author

pgroene commented Sep 18, 2023

@TheJulianJES what are the steps to get this merged?

@Coysh
Copy link

Coysh commented Dec 8, 2023

@SavoryLikeBacon - So you've tried this with qasjif9e and it's not working?

@pgroene
Copy link
Author

pgroene commented Dec 10, 2023

@Coysh @SavoryLikeBacon Can you use this older version of the quirk:
https://raw.githubusercontent.com/zigpy/zha-device-handlers/c7b130a20614e3e364c9fea023d632014a5726d1/zhaquirks/tuya/ts0601_motion.py

This version is working, the current version is not working because we try to make some breaking changes that have to go on myltiple places.

@SavoryLikeBacon
Copy link

SavoryLikeBacon commented Dec 16, 2023

Hi @Coysh and @pgroene,

I appreciate the work.
I did try the code above and my qasjif9e _does _ work now! Thanks!

@checklyalex
Copy link

@Coysh @SavoryLikeBacon Can you use this older version of the quirk: https://raw.githubusercontent.com/zigpy/zha-device-handlers/c7b130a20614e3e364c9fea023d632014a5726d1/zhaquirks/tuya/ts0601_motion.py

This version is working, the current version is not working because we try to make some breaking changes that have to go on myltiple places.

Confirmed working. I have a _TZE204_e5m9c5hl and can see the controls and occupency sensor in HA.

@Coysh
Copy link

Coysh commented Dec 22, 2023

@Coysh @SavoryLikeBacon Can you use this older version of the quirk: https://raw.githubusercontent.com/zigpy/zha-device-handlers/c7b130a20614e3e364c9fea023d632014a5726d1/zhaquirks/tuya/ts0601_motion.py

This version is working, the current version is not working because we try to make some breaking changes that have to go on myltiple places.

Yep - this one is working for me, see attached:
CleanShot 2023-12-22 at 16 39 51@2x

Not sure if it should be logging the history of the controls though, but I'm not experienced in these things.

@Goaheadz
Copy link

So I just received a new mmwave sensor TS0601 by _TZE204_muvkrjr5 from Aliexpress.
I followed the above steps copying the TS0601.py file, but only LDI and RSSI is showed as expected (restart also done) cause no one talks about this sensor variant.

I am new to all this. I thougth integration would be straight, but I guess I need a quirk file to make parameters available in Home Assistant :(

Can someone help?

image

https://pt.aliexpress.com/item/1005006412041826.html?spm=a2g0o.order_list.order_list_main.29.52afcaa4H5VTTL&gatewayAdapt=glo2bra

@Goaheadz
Copy link

TZE204_muvkrjr5

INFO (MainThread) [zigpy.endpoint] [0xb905:1] Discovered endpoint information: SizePrefixedSimpleDescriptor(endpoint=1, profile=260, device_type=81, device_version=1, input_clusters=[4, 5, 61184, 0], output_clusters=[25, 10])

@thefunkygibbon
Copy link

Hi @Coysh and @pgroene,

I appreciate the work. I did try the code above and my qasjif9e _does _ work now! Thanks!

does yours report motion/presence/illuminance and detected distance? i have TZE204_qasjif9e but I can't seem to get anything to work other than the presence and illum and thats using https://fixtse.com/blog/zy-m100-full-zha-support , I can't get any of them to work from ones i've found in here or other places on github :-|

@thefunkygibbon
Copy link

just to add/clarify, I'm have used the py code above, replaced the signature to reflect my model but it never seems to pick up on this quirk, restarted ha and re-paired the sensor but still nothing. just picks up default quirk. I'm unsure why. nothing is in logs saying it can't parse it. it should at least pick it up and use it even if it doesnt work

@Goaheadz
Copy link

just to add/clarify, I'm have used the py code above, replaced the signature to reflect my model but it never seems to pick up on this quirk, restarted ha and re-paired the sensor but still nothing. just picks up default quirk. I'm unsure why. nothing is in logs saying it can't parse it. it should at least pick it up and use it even if it doesnt work

First you need to make sure, that quirk was loaded:
image

@thefunkygibbon
Copy link

yes thats what i'm saying, it wasn't loaded; it is using the default quirk still

@Goaheadz
Copy link

You have the .py file in this location and those lines of code in configuration.yaml?
image
image
If you have all this, and after a HA restart it doesn't load the costume quirk, then you must have a mistype somewhere.

@Goaheadz
Copy link

And I think you should delete the pycache folder, so HA can rebuild it with new quirk.

@thefunkygibbon
Copy link

yes, all those aspects are fine. i'm using other quirks for other devices. and using a different quirk for this device works, just this quirk doesnt and i REALLY need the target distance aspect to work, and i didnt know i could get the temp from it too

@thefunkygibbon
Copy link

thefunkygibbon commented Feb 14, 2024

to be clear, I changed

signature = {
    MODELS_INFO: [("_TZE204_yensya2c", "TS0601")],

and replaced with

signature = {
    MODELS_INFO: [("_TZE204_qasjif9e", "TS0601")],

and copied it as is. so I don't see how i could have typo'd

@thefunkygibbon
Copy link

thefunkygibbon commented Feb 15, 2024

i'm sure it is something to do with the code so that it isn't just that line of the py file signature that causes HA to associate the quirk with it.
thanks for your help. hopefully one of the others who have used this with my model can chime in (or @3dbluebot who wrote it)

@llucax
Copy link

llucax commented Mar 1, 2024

@Coysh @SavoryLikeBacon Can you use this older version of the quirk: https://raw.githubusercontent.com/zigpy/zha-device-handlers/c7b130a20614e3e364c9fea023d632014a5726d1/zhaquirks/tuya/ts0601_motion.py

This version is working, the current version is not working because we try to make some breaking changes that have to go on myltiple places.

In case it is useful, I can confirm this version works for me too for _TZE204_e5m9c5hl. Awesome, thanks! I hope this PR is sorted out soon and the support is merged.

@nirajbhatt7
Copy link

@Coysh @SavoryLikeBacon Can you use this older version of the quirk: https://raw.githubusercontent.com/zigpy/zha-device-handlers/c7b130a20614e3e364c9fea023d632014a5726d1/zhaquirks/tuya/ts0601_motion.py
This version is working, the current version is not working because we try to make some breaking changes that have to go on myltiple places.

In case it is useful, I can confirm this version works for me too for _TZE204_e5m9c5hl. Awesome, thanks! I hope this PR is sorted out soon and the support is merged.

This version worked for me with following

  • Only detects when someone is at 5 ft / 1.5 meter (Max is set to maximum and minimum is set to 0)
  • After someone leaves the room, the "Away" triggers after about 20 to 30 seconds
  • LUX sensor/values are not available

@rrooggiieerr
Copy link

It would be great if these Tuya MMW Sensors would have native support in ZHA and no custom quirk was needed. Is there any reason this quirk is not incorporated in ZHA? What's holding it back?

@thefunkygibbon
Copy link

It would be great if these Tuya MMW Sensors would have native support in ZHA and no custom quirk was needed. Is there any reason this quirk is not incorporated in ZHA? What's holding it back?

mainly because Tuya don't adhere to the Zigbee standard.

@TheJulianJES
Copy link
Collaborator

Documentation isn't quite ready yet, but all "fake" AnalogInput cluster for settings can be replaced with quirks v2 config entities.

@pgroene
Copy link
Author

pgroene commented Apr 6, 2024

to be clear, I changed

signature = {
    MODELS_INFO: [("_TZE204_yensya2c", "TS0601")],

and replaced with

signature = {
    MODELS_INFO: [("_TZE204_qasjif9e", "TS0601")],

and copied it as is. so I don't see how i could have typo'd

I do not think those are the same, just replacing the signature will not get it to work. You have to do the mapping for the yensya2c to get it to work.

@Cybermb
Copy link

Cybermb commented May 30, 2024

What is status for this PR?
Are there plans to add fretting, presence, motion, distance detections? As in current state and in terms of functionality, it functions as a cheap PIR sensor, just more precise and a bit more control (with this quirk). There are no states for person standing, sitting, walking, jumping, etc...

@pgroene
Copy link
Author

pgroene commented Jun 20, 2024

I have moved to zigbee2mqtt for these devices. After there was issue in HA where these devices took down my network (ZHA) plus the time it takes to get all requirements to make this ready for merging, I have spend my time re-pairing my devices once to MQTT and the work fine.

@Coysh
Copy link

Coysh commented Jul 7, 2024

I've finally got around to trying this and encountering a weird performance issue. Has anyone else experienced this? There is no one in or around the room, but the device keeps becoming unavailable?

Sensitivity set to 6 and distance 600

CleanShot 2024-07-07 at 20 35 45@2x

@TheJulianJES TheJulianJES added the help wanted Extra attention is needed label Aug 26, 2024
@thefunkygibbon
Copy link

anyone got a better quirk for these devices yet?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed Tuya Request/PR regarding a Tuya device
Projects
None yet
Development

Successfully merging this pull request may close these issues.